#!/usr/bin/env nextflow

nextflow.enable.dsl=2

// params.fastq = ""
// params.sample_id = ""

process FastqToFasta {
    tag "$sample_id"

    input:
    val(sample_id) 
    path(fastq_file)
    
    output:
    path "${sample_id}.fasta", emit: fasta

    script:
    """
    gzip -dc ${fastq_file} | awk '{if((NR-1)%4 < 2){print \$1}}' |sed "s/^@/>/"  > ${sample_id}.fasta
    """
}

workflow {
    infiles = Channel.fromPath(params.fastq)
    // ids = Channel.from(params.sample_id)
    ids = Channel.fromList(params.sample_id) //fromList New in version 19.10.0.

    FastqToFasta(ids,infiles).fasta.view()
}
